addLocalSourceFromJSON

abstract fun addLocalSourceFromJSON(contentJSON: String, basePath: String? = null, matcher: List<String>? = null): String

Creates a new local asset source from a JSON string containing asset definitions.

The JSON structure should contain a version field, an id field specifying the asset source identifier, and an assets array with asset definitions. Each asset should have an id, localized label object, and a meta object containing asset-specific properties like uri, thumbUri, blockType, etc.

Optionally, you can provide a matcher list of patterns to filter which assets are loaded based on their IDs. The matcher patterns support wildcards using *. An asset is included if it matches ANY of the patterns.

Return

The ID of the newly created asset source (as specified in the JSON's id field).

Parameters

contentJSON

The JSON string containing the asset definitions.

basePath

An optional base path with which {{base_url}} strings in the assets should be replaced. If no value is provided, settings.basePath is used.

matcher

Optional list of matcher patterns to filter assets by ID. Supports * wildcard. An asset is included if it matches ANY pattern.


abstract suspend fun addLocalSourceFromJSON(contentUri: Uri, matcher: List<String>? = null): String

Creates a new local asset source from a JSON Uri.

Loads and parses a JSON file from the specified Uri to create an asset source. The JSON structure should contain a version field, an id field specifying the asset source identifier, and an assets array with asset definitions. The created asset source will have the ID specified in the JSON's id field, and all assets defined in the JSON will be added to the source.

Note: The parent directory of the content.json Uri will be used as the base path for resolving relative URLs in the asset definitions (e.g., {{base_url}} placeholders).

Return

The ID of the newly created asset source (as specified in the JSON's id field).

Parameters

contentUri

The Uri for the JSON file to load and parse.

matcher

Optional list of matcher patterns to filter assets by ID. Supports * wildcard. An asset is included if it matches ANY pattern.